#include <iostream>
#include <string>
int main() {
    using namespace std;
    int a[] = {4,3,2,5,3,1,4,8};
    int n = sizeof(a)/sizeof(a[0]);
    int max = 0;
    int i=0;
    bool flag = true;
    while(flag)
    {

        int count=0;
        for(;i<n-1;i++)
        {

            if(a[i]>a[i+1])
            {
                if(i == n-2)
                {
                    flag = false;
                }
                count++;
                cout<<"count:"<<count+1<<" a["<<i<<"]="<<a[i]
                    <<">"<<"a[" <<i+1<<"]="<<a[i+1]<<endl;
//                cout<<"a[i]="<<">"<<" a[i+1] = "<<a[i+1]<<endl;
            }
            else
            {
                i = count+1;
                count = 0;
                cout<<"山谷长度:"<<count+1<<endl;
                continue;
            }

        }
    }
    return 0;
}